package com.se.common;

import org.apache.commons.codec.digest.DigestUtils;

import java.io.Serial;
import java.io.Serializable;

public class Message implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;
    private String sendUser;
    private String receiveUser;
    private String content;
    private String sendTime;
    private String msgType;
    private boolean isAI;
    private String id;  //仅在消息为AI消息时使用
    private int currentDisplayIndex = 0;

    public int getCurrentDisplayIndex() {
        return currentDisplayIndex;
    }

    public void setCurrentDisplayIndex(int currentDisplayIndex) {
        this.currentDisplayIndex = currentDisplayIndex;
    }

    public boolean isAI() {
        return isAI;
    }

    public void setAI(boolean isAI) {
        this.isAI = isAI;
    }

    public String getId() {
        if(id == null) {
            id = DigestUtils.sha256Hex(getContent());
        }
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getMsgType() {
        return msgType;
    }

    public void setMsgType(String msgType) {
        if(msgType == null) {
            return;
        }
        this.msgType = msgType;
    }

    public String getSendTime() {
        return sendTime;
    }

    public void setSendTime(String sendTime) {
        if(sendTime == null) {
            return;
        }
        this.sendTime = sendTime;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        if(content == null) {
            return;
        }
        this.content = content;
    }

    public String getReceiveUser() {
        return receiveUser;
    }

    public void setReceiveUser(String receiveUser) {
        if(receiveUser == null) {
            return;
        }
        this.receiveUser = receiveUser;
    }

    public String getSendUser() {
        return sendUser;
    }

    public void setSendUser(String sendUser) {
        if(sendUser == null) {
            return;
        }
        this.sendUser = sendUser;
    }
}
